<template>
  <div>
    <h1>Count-{{ tenSumAndOne }}</h1>
    <h1>我在{{ school }}学{{ subject }}</h1>

    <h2>当前求和为{{ sum }}</h2>
    <select v-model.number="n">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="increment(n)">+</button>
    <button @click="decrement(n)">-</button>
    <button @click="incrementOdd(n)">奇数+</button>
    <button @click="incrementWait(n)">等一等+</button>
    <div style="color: red">
      <ul>
        <li v-for="p in personList" :key="p.id">{{ p.name }}</li>
      </ul>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import { mapGetters } from "vuex";
import { mapActions } from "vuex";
import { mapMutations } from "vuex";
export default {
  data: function () {
    return {
      n: 1,
    };
  },
  computed: {
    ...mapState("countState", ["sum", "school", "subject"]),
    ...mapGetters("countState", ["tenSumAndOne"]),
    ...mapState("personState", ["personList"]),
  },
  mounted() {
    console.log(this.$store);
  },
  methods: {
    ...mapActions("countState", {
      incrementOdd: "incrementIfOdd",
      incrementWait: "incrementAsync",
    }),
    ...mapMutations("countState", {
      decrement: "DECREMENT",
      increment: "INCREMENT",
    }),
  },
};
</script>

<style scoped>
button {
  margin-left: 10px;
}
</style>